import Vuex from 'vuex'
import Vue from 'vue'

Vue.use(Vuex)

const actions = {
    current_video(context, value) {
        context.commit('CURRENT_VIDEO', value)
    },
    current_practice(context, value) {
        context.commit('CURRENT_PRACTICE', value)
    },
    current_bank(context, value) {
        context.commit('CURRENT_BANK', value)
    },
    current_answers(context, value) {
        context.commit('CURRENT_ANSWERS', value)
    },
    set_user(context, value) {
        context.commit('CURRENT_USER', value)
    },
    set_router(context, value) {
        context.commit('ROUTER_DATA', value)
    },
    set_refresh(context, value) {
        context.commit('SET_REFRESH', value)
    }
}

const mutations = {
    CURRENT_VIDEO(state, value) {
        state.currentVideo = value
    },
    CURRENT_PRACTICE(state, value) {
        state.currentPractice = value
    },
    CURRENT_BANK(state, value) {
        state.currentBank = value
    },
    CURRENT_ANSWERS(state, value) {
        state.currentAnswers = value
    },
    CURRENT_USER(state, value) {
        state.currentUser = value
    },
    ROUTER_DATA(state, value) {
        state.routerData = value
    },
    SET_REFRESH(state, value) {
        state.isRefresh = value
    }
    
}

const state = {
    currentVideo: '',
    currentPractice: '',
    currentBank: '',
    currentAnswers: [],
    currentUser: {},
    routerData: [],
    isRefresh: true
}

const getters = {
    getCurrentVideo(state) {
        return state.currentVideo
    }
}

const store = new Vuex.Store({
    actions,
    mutations,
    state,
    getters
})


export default store